package 题目集.hash;

import org.junit.Test;

public class dem02_哈希与同余原理 {
    public long countCompleteDayPairs(int[] hours) {
        int[] cnt = new int[24];
        long res = 0;
        for (int h : hours) {
            int v = (24 - h % 24)%24; /*再模一次，防止h=24的情况*/
            res += cnt[v];
            cnt[h % 24]++;
        }
        return res;
    }
    @Test
    public void test(){
        int[] arr={12,12,30,24,24};
        System.out.println(countCompleteDayPairs(arr));
    }
}
